package com.kgcx.organization.controller;
import com.kgcx.common.bean.RequestData;
import com.kgcx.common.bean.ReturnData;
import com.kgcx.common.constant.ResultCode;
import com.kgcx.common.controller.BaseController;
import com.kgcx.organization.domain.StationParking;
import com.kgcx.organization.service.StationParkingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(description = "站务泊车位", tags = "接口")
@RestController
@RequestMapping("stationParking")
public class StationParkingController extends BaseController {
	@Autowired
	private StationParkingService stationParkingService;

	@ApiOperation(value = "新增站务泊车位", httpMethod = "POST", notes = "接口")
	@PostMapping("addStationParking")
	public ReturnData<?> addStationParking(@RequestBody StationParking stationParking) {
		stationParkingService.addStationParking(stationParking);
		return new ReturnData<>();
	}

	@ApiOperation(value = "修改站务泊车位", httpMethod = "POST", notes = "接口")
	@PostMapping("updateStationParking")
	public ReturnData<?> updateStationParking(@RequestBody StationParking stationParking) {
		stationParkingService.updateStationParking(stationParking);
		return new ReturnData<>();
	}

	@ApiOperation(value = "根据kid查找站务泊车位", httpMethod = "POST", notes = "接口")
	@PostMapping("getStationParking")
	@ApiImplicitParam(name = "kid", value = "1", required = true, paramType = "query", dataType = "Long", dataTypeClass = Long.class)
	public ReturnData<?> getStationParking(Long kid) {
		ReturnData<StationParking> returnData = ReturnData.getResult();
		StationParking stationParking = stationParkingService.getStationParking(kid);
		returnData.setData(stationParking);
		returnData.setCode(ResultCode.SUCCESS);
		returnData.setMsg("查询成功");
		return returnData;
	}

	@ApiOperation(value = "分页查询站务泊车位", httpMethod = "POST", notes = "接口")
	@PostMapping("getStationParkingList")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "pageNum", value = "页码", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
			@ApiImplicitParam(name = "pageSize", value = "页容量", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
			@ApiImplicitParam(name = "stationId", value = "站务id", required = false, paramType = "query", dataType = "Long", dataTypeClass = Long.class),
			@ApiImplicitParam(name = "stationExitId", value = "出站口id", required = false, paramType = "query", dataType = "Long", dataTypeClass = Long.class) })
	public ReturnData<?> getStationParkingList() {
		ReturnData<List<StationParking>> returnData = ReturnData.getResult();
		RequestData requestData = this.getRequestData();
		List<StationParking> list = stationParkingService.getStationParkingList(requestData);
		returnData.setData(list);
		returnData.setCode(ResultCode.SUCCESS);
		returnData.setMsg("查询成功");
		return returnData;
	}
}
